﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure.ServiceRuntime;

namespace BasicClasses
{
    public class EspecializacaoDataSource
    {
        private static EspecializacaoContext context = new EspecializacaoContext();
        private static string tableName = RoleEnvironment.GetConfigurationSettingValue("EspecializacaoTable");

        public static IEnumerable<Especializacao> SelectAll()
        {
            return context.Especializacoes;
        }

        public static void Add(Especializacao especializacao, string partitionKey) //partitionKey == Pais
        {
            especializacao.PartitionKey = partitionKey;
            especializacao.RowKey = Guid.NewGuid().ToString();
            context.AddObject(tableName, especializacao);
            context.SaveChanges();
        }

        public static void Add(Especializacao especializacao)
        {
            Add(especializacao, "_default");
        }
    }
}
